package com.ruoyi.civil.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.civil.domain.CivilEnginneeringCleaning;
import com.ruoyi.civil.service.ICivilEnginneeringCleaningService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清洁Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/civil/cleaning")
public class CivilEnginneeringCleaningController extends BaseController
{
    @Autowired
    private ICivilEnginneeringCleaningService civilEnginneeringCleaningService;

    /**
     * 查询清洁列表
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:list')")
    @GetMapping("/list")
    public TableDataInfo list(CivilEnginneeringCleaning civilEnginneeringCleaning)
    {
        startPage();
        List<CivilEnginneeringCleaning> list = civilEnginneeringCleaningService.selectCivilEnginneeringCleaningList(civilEnginneeringCleaning);
        return getDataTable(list);
    }

    /**
     * 导出清洁列表
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:export')")
    @Log(title = "清洁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CivilEnginneeringCleaning civilEnginneeringCleaning)
    {
        List<CivilEnginneeringCleaning> list = civilEnginneeringCleaningService.selectCivilEnginneeringCleaningList(civilEnginneeringCleaning);
        ExcelUtil<CivilEnginneeringCleaning> util = new ExcelUtil<CivilEnginneeringCleaning>(CivilEnginneeringCleaning.class);
        util.exportExcel(response, list, "清洁数据");
    }

    /**
     * 获取清洁详细信息
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:query')")
    @GetMapping(value = "/{tCleanId}")
    public AjaxResult getInfo(@PathVariable("tCleanId") Long tCleanId)
    {
        return AjaxResult.success(civilEnginneeringCleaningService.selectCivilEnginneeringCleaningByTCleanId(tCleanId));
    }

    /**
     * 新增清洁
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:add')")
    @Log(title = "清洁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CivilEnginneeringCleaning civilEnginneeringCleaning)
    {
        return toAjax(civilEnginneeringCleaningService.insertCivilEnginneeringCleaning(civilEnginneeringCleaning));
    }

    /**
     * 修改清洁
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:edit')")
    @Log(title = "清洁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CivilEnginneeringCleaning civilEnginneeringCleaning)
    {
        return toAjax(civilEnginneeringCleaningService.updateCivilEnginneeringCleaning(civilEnginneeringCleaning));
    }

    /**
     * 删除清洁
     */
    @PreAuthorize("@ss.hasPermi('civil:cleaning:remove')")
    @Log(title = "清洁", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tCleanIds}")
    public AjaxResult remove(@PathVariable Long[] tCleanIds)
    {
        return toAjax(civilEnginneeringCleaningService.deleteCivilEnginneeringCleaningByTCleanIds(tCleanIds));
    }
}
